package study.week05.gateway.netty;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import study.week05.gateway.filter.CustomHttpFilter;
import study.week05.gateway.inbound.InboundHandler;
import study.week05.gateway.outbound.OutboundHandler;
import study.week05.gateway.router.CustomRouter;

import java.util.List;
import java.util.concurrent.ExecutorService;

public class HttpInitializer extends ChannelInitializer<SocketChannel> {

	InboundHandler inboundHandler;
	public HttpInitializer( InboundHandler inboundHandler) {
		this.inboundHandler =  inboundHandler;
	}
	@Override
	public void initChannel(SocketChannel ch) {
		ChannelPipeline p = ch.pipeline();
		p.addLast(new HttpServerCodec());
		//p.addLast(new HttpServerExpectContinueHandler());
		p.addLast(new HttpObjectAggregator(1024 * 1024));
		p.addLast(inboundHandler);
	}
}